//
//  YIem_Find_FoundViewModel.m
//  B段_开眼
//
//  Created by YIem on 16/4/27.
//  Copyright © 2016年 Howie. All rights reserved.
//

#import "YIem_Find_FoundViewModel.h"

@implementation YIem_Find_FoundViewModel
 + (void)getDataWithPage:(NSString *)nextPage andUpdate:(BOOL)isUpdate andBlock:(void (^)(NSMutableArray *))tableArr
{
    NSMutableArray *array = [NSMutableArray array];
    NSMutableArray *array1 = [NSMutableArray array];
    NSMutableArray *array2 = [NSMutableArray array];
    
    [CustomerNetWorking connectWithURL:nextPage andUpdate:isUpdate andBlock:^(id response) {
       
        NSArray *arr = [response objectForKey:@"pgcList"];
//        NSLog(@"%ld", arr.count);
        for (NSDictionary *dic in arr) {
            NSMutableArray *tempArr = [NSMutableArray array];
            for (NSInteger i = 0; i < [[dic objectForKey:@"itemList"] count]; i++) {
                YIem_Find_FoundCellModel *model = [[YIem_Find_FoundCellModel alloc] init];
                [model setValuesForKeysWithDictionary:[[[dic objectForKey:@"itemList"] objectAtIndex:i] objectForKey:@"data"]];
                if (i == 0) {
                    [array1 addObject:model];
                } else {
                    [tempArr addObject:model];
                }
            }
            [array2 addObject:tempArr];
        }
        [array addObject:array1];
        [array addObject:array2];
//        NSLog(@"%@", array);
        tableArr(array);
        
    }];
    
    
    
    
}
@end
